﻿/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A
 * copy of the license can be found at http://go.microsoft.com/fwlink/?LinkID=131993. If
 * you cannot locate the Microsoft Public License, please send an email to
 * mixon@microsoft.com. By using this source code in any fashion, you are agreeing to
 * be bound by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 *
 * ***************************************************************************/

using System;
using System.Windows.Data;

namespace MIXOnline.Descry
{
    /// <summary>
    /// Convert a FriendFeed username to an avatar image source path as a URL
    /// </summary>
    public class AvatarConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string imagesize = parameter as string;
            if (string.IsNullOrEmpty(imagesize))
                imagesize = "large";

            return "http://friendfeed.com/" + value as string + "/picture?size=" + imagesize;
        }

        // ConvertBack is not implemented for a OneWay binding. 
        // NOTE: This causes XAML parsing to fail unless you explictly set Mode=OneWay in XAML, even when returning null;
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}


